<?php
/**
 * Created by PhpStorm.
 * User: koterwong
 * Date: 2017/8/29
 * Time: 16:55
 */

namespace app\api\controller;

use app\api\model\PortalCategoryModel;
use think\Db;

class PhotoController extends ApiBaseController
{

    /**
     * 获取一二级分类
     */
    public function cateTree()
    {
        $cateModel = new PortalCategoryModel();
        returnData(200, '', $cateModel->getTree());
    }

    /**
     * 获取三级分类
     */
    public function getChildrenById()
    {
        $id = input('id');

        if (empty($id) && $id != 0) {
            returnError(API_PARAM_ERROR, '缺少参数id');
        }

        $cateModel = new PortalCategoryModel();
        returnData(200, '', $cateModel->getChildrenById($id));
    }

    /**
     * 获取图片列表
     */
    public function getPhoto()
    {
        //三级级分类id
        $id = input('id');
        $page= input('page','0');
        $page_size= input('page_size','10');
        if (empty($id) && $id != 0){
            returnError(API_PARAM_ERROR, '缺少参数id');
        }
        $cateModel = new PortalCategoryModel();
        $list=$cateModel->getPhoto($id,$page,$page_size);
        if($list) {
            returnData(200, '', $list);
        }else{
            returnData(100, '暂无数据', array());
        }
    }

    /**
     * 查看图片
     */
    public function viewPhoto(){
        $id=input('id');
        $cateModel = new PortalCategoryModel();
        $list=$cateModel->viewPhoto($id);
    }


}